package com.example.myapplication;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.SimpleAdapter;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.HashMap;

public class MyList3Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_list3);
        ListView listView=findViewById(R.id.mylist3);
        ProgressBar progressBar=findViewById(R.id.progressBar);
        progressBar.setVisibility(View.GONE);

        ArrayList<HashMap<String, String>> listItems=new ArrayList<>();
        for(int i=0;i<10;i++){
            HashMap<String,String> map=new HashMap<String,String>();
            map.put("ItemTitle","Rate:" +i);
            map.put("ItemDetail","detail:" +i);
            listItems.add(map);
        }
        SimpleAdapter listItemAdapter=new SimpleAdapter(this,
                listItems,
                R.layout.list_item,
                new String[]{"ItemTitle","ItemDetail"},
                new int[]{R.id.itemTitle,R.id.itemDetail}
        );
        listView.setAdapter(listItemAdapter);
        listView.setVisibility(View.VISIBLE);
        //获取网络数据
        Handler handler=new Handler(){
            @Override
            public void handleMessage(@NonNull Message msg) {
                if (msg.what==9){
                    ArrayList<String> list3=(ArrayList<String>)msg.obj;
                    ListAdapter adapter=new ArrayAdapter<String>(MyList3Activity.this,
                            android.R.layout.simple_list_item_1,list3);
                    //显示隐藏


                }
                super.handleMessage(msg);
            }
        };
        MyTask task=new MyTask();
        task.setHandler(handler);
        Thread t=new Thread(task);
        t.start();
    }
}